﻿using System;
using System.Collections.Generic;
using System.Text;
using Log4Nez.Loggers;
using Log4Nez.Enumerations;
using System.Xml;
using Log4Nez.Resources;
using Log4Nez.Exceptions;
using System.IO;
using System.Collections.Specialized;
using Log4Nez.Interfaces;

namespace Log4Nez.Factories
{
    internal static class LoggerFactoriesProxy
    {
        private static XmlDocument xmlSettings;

        public static ILogger CreateLogger(XmlNode loggerNode)
        {
            try
            {
                ILogger logger = null;
                LoggerType logType;
                Enum.TryParse(loggerNode.Name, out logType);
                switch (logType)
                {
                    case LoggerType.CvsLogger:
                        logger = FileLoggerFactory.CreateFileLogger(loggerNode, logType);
                        break;
                    case LoggerType.DatabaseLogger:
                        logger = DatabaseLoggerFactory.CreateDatabaseLogger(loggerNode, logType);
                        break;
                    case LoggerType.EventLogLogger:
                        logger = EventLoggerFactory.CreateEventLogLogger(loggerNode, logType);
                        break;
                    default:
                        logger = null;
                        break;
                }

                return logger;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                throw new FactoryException(string.Format(ExceptionMessages.InvalidLoggerType, ex.ParamName));
            }
        }

        private static void loadConfig()
        {
            xmlSettings = new XmlDocument();
            string path = "";
            xmlSettings.Load(path);

            
            XmlNodeList nodiLoggers = xmlSettings.SelectNodes("");
            
            
        }
    }
}
